package service.visitor;

import dao.visitor.VisitorDao;
import dao.visitor.VisitorDaoImpl;
import domain.Visitors;

import java.util.ArrayList;

public class VisitorServiceImpl implements VisitorService {
    VisitorDao visitorDao= new VisitorDaoImpl();
    /**
     * 新建访客信息
     * @param room_id,community_id,name,phone,idcard,carid,photo_img,reason,cometime,validtime
     * @return int
     * @author 夏天
     * @date 2020/7/23 15:07
     */
    @Override
    public int CreatVisitor(int room_id,int community_id,String name,String phone,String idcard,String carid,String photo_img,String reason,String cometime,String validtime){
        int i =0;
        try {
            i = visitorDao.CreatVisitor(room_id,community_id,name,phone,idcard,carid,photo_img,reason,cometime,validtime);
        }catch (Exception e){
            e.printStackTrace();
        }
        return i;
    }

    /**
     * 通过room_id查询访客列表
     * @param room_id
     * @return ArrayList
     * @author 夏天
     * @date 2020/7/23 15:18
     */
    @Override
    public ArrayList<Visitors> getVisitors(int room_id){
        ArrayList<Visitors> list =new ArrayList<>();
        try {
            list = visitorDao.getVisitors(room_id);
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 删除访客信息
     * @param visitors_id
     * @return int
     * @author 夏天
     * @date 2020/7/23 15:31
     */
    @Override
    public  int DelectVisitors(int visitors_id){
        int i =0;
        try {
            i = visitorDao.DelectVisitors(visitors_id);
        }catch (Exception e){
            e.printStackTrace();
        }
        return i;
    }

    /**
     * 查看单条数据的详细信息
     * @param visitors_id
     * @return Visitors
     * @author 夏天
     * @date 2020/7/23 15:37
     */
    public  Visitors seeInfo(int visitors_id){
        Visitors visitors =new Visitors();
        try {
            visitors = visitorDao.seeInfo(visitors_id);
        }catch (Exception e){
            e.printStackTrace();
        }
        return visitors;
    }
    /**
     * 更新访客信息
     * @param visitors_id,phone,idcard,carid,photo_img,reason,cometime,validtime
     * @retrun int
     * @author 夏天
     * @date 2020/7/23 16:09
     */
    public  int UpdateVisitor(int visitors_id,String phone,String idcard,String carid,String photo_img,String reason,String cometime,String validtime){
        int i =0;
        try {
            i = visitorDao.UpdateVisitor(visitors_id,phone,idcard,carid,photo_img,reason,cometime,validtime);
        }catch (Exception e){
            e.printStackTrace();
        }
        return i;
    }
}
